<template>
  <h2>依赖注入</h2>
  <Child />
</template>

<script>
import Child from "./15-child.vue";
import { provide, ref, onMounted } from "vue";
export default {
  components: {
    Child,
  },
  setup() {
    const name = ref("zhangsan");
    // provide作为函数调用，里面两个参数，分别key和value
    // 配合上ref，就能完美地解决响应式的问题了
    // provide("name", name);

    onMounted(() => {
      setTimeout(() => {
        name.value = "lisi";
      }, 2000);
    });
  },
};
</script>
